package com.cf.user.login.model;

import com.cf.code.core.CField;
import com.cf.code.core.CModel;
import com.cf.code.core.CPage;
import com.cf.crud.entity.BaseEntity;
import com.cf.user.core.EnumUserType;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * game-server-UserInfo
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/5/28 下午 07:24
 */
@Entity
@Table(name = "userInfo",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = {"phone"}),
                @UniqueConstraint(columnNames = {"email"})
        }
)
@CModel(pages = {
        @CPage(title = "用户列表", path = "userInfo", templateName = "list.ftl", outPutName = "list.ftl"),
        @CPage(title = "用户", path = "userInfo", templateName = "add.ftl", outPutName = "add.ftl"),
        @CPage(title = "用户", path = "userInfo", templateName = "update.ftl", outPutName = "update.ftl")
})
public class UserInfo extends BaseEntity {

    @CField(lab = "名字", search = true)
    private String name;

    @CField(lab = "性别")
    private Integer sex;

    @CField(lab = "头像", type = "file")
    private String head;

    @CField(lab = "手机号")
    private String phone;

    @CField(lab = "邮箱")
    private String email;

    @CField(lab = "国家")
    private String country;

    @CField(lab = "省份")
    private String province;

    @CField(lab = "城市")
    private String city;

    @CField(lab = "生日", type = "date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    private Date birth;

    private String type = EnumUserType.COMMON.getCode();

    public UserInfo() {
    }

    public UserInfo(long id, String name, String head) {
        this.id = id;
        this.name = name;
        this.head = head;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getHead() {
        return head;
    }

    public void setHead(String head) {
        this.head = head;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }
}
